<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020-02-23
 * Time: 10:09
 */

namespace app\cms\model;


use think\Model;

class News extends Model
{
    protected $name = "cms_news";

    // 关闭自动写入时间戳
    protected $autoWriteTimestamp = true;
    // 定义时间戳字段名
    protected $createTime = 'newstime';
    protected $updateTime = 'lastdotime';

    // 定义自动完成的属性
    protected $insert = ['checked' => 1];

    //  checked读取器
    protected function getCheckedAttr($value){
        $status = [0 => '未审核', 1 => '已审核'];
        return $status[$value];
    }

    //  读取器
    protected function getIsmemberAttr($value){
        $status = [0 => '后台发布', 1 => '前台发布'];
        return $status[$value];
    }

    //  读取器
    protected function getNewstimeAttr($value){
        return empty($value)?"":date('Y-m-d H:i:s',$value);
    }
    //  修改器
    protected function setNewstimeAttr($value){
        return strtotime($value);
    }

}